#include <bits/stdc++.h>
#define debug(x) cout << x << endl;
using namespace std;

const int N = 3010 + 10;

struct Car{
	int d, v, a;
}car[N];

int res;
int n, m, L, V;
int pos[N];
int st[N];
int st2[N];
int vis[N];
vector<int> dt[N];

typedef long long LL;

void dfs(int u, int s)
{
	if(s >= res) return;
	if(u) for(int i = 0; i < (int)dt[u].size(); ++ i) st[dt[u][i]] = 1;
	if(u == m)
	{
		int f = 1;
		for(int i = 1; i <= n; ++ i)
		{
			if(st2[i]) continue;
			if(!st[i])
			{
				f = 0;
				break;
			}
		}
		if(f) res = min(res, s);
		return;
	}
	for(int i = u + 1; i <= m; ++ i)
		dfs(i, s + 1);
	if(u) for(int i = 0; i < (int)dt[u].size(); ++ i) st[dt[u][i]] = 0;
}

int main()
{
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	int T;
	cin >> T;
	while(T --)
	{
		cin >> n >> m >> L >> V;
		int cnt = 0;
		res = m;
		
		memset(st, 0, sizeof st);
		memset(vis, 0, sizeof vis);
		memset(st2, 0, sizeof st2);
		for(int i = 1; i <= n; ++ i) scanf("%d%d%d", &car[i].d, &car[i].v, &car[i].a);
		
		for(int i = 1; i <= m; ++ i)
		{
			dt[i].clear();
			int x;
			scanf("%d", &x);
			vis[x] = 1;
			pos[x] = i;
		}
		for(int i = 1; i <= n; ++ i)
		{
			int sv = car[i].v;
			int f = 0;
			
			for(int j = car[i].d; j <= L; ++ j)
			{
				if(sv <= 0) break;
				
				if(sv > V && vis[j])
				{
					dt[pos[j]].push_back(i);
					f = 1;
				}
				
				sv += car[i].a;
			}
			if(f) cnt ++;
			else st2[i] = 1;
		}

		cout << cnt << ' ';		
		dfs(0, 0);
		
		cout << m - res << endl;
	}
	return 0;
}
